package com.dingwei.lesyndrome.mvp.presenter;

import com.dingwei.lesyndrome.base.FailsBean;
import com.dingwei.lesyndrome.base.MyBaseBean;
import com.dingwei.lesyndrome.custom.myCallback;
import com.dingwei.lesyndrome.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.base.URLS;
import com.lihao.baselibrary.base.basePresenter;

import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by lihao on 2017/9/12.
 */

public class ModifyNamePresenter extends basePresenter {

    private Contract.ModifyNameView modifyNameView;

    public ModifyNamePresenter(Contract.ModifyNameView view) {
        super(view);
        this.modifyNameView = view;
    }

    public void saveName(final String nickname) {

        RequestParams rp =new RequestParams(URLS.HOST+URLS.SAVE_DATA);
        rp.addBodyParameter("sessionid", BaseActivity.value.getToken());
        rp.addBodyParameter("nickname",nickname);
        x.http().post(rp, new myCallback(BaseActivity.context,MyBaseBean.class,rp) {
            @Override
            public void back(MyBaseBean baseBean, String result) {
                showToast(baseBean.message);
                modifyNameView.saveNickNameSuccess(nickname);
            }

            @Override
            public void fail(FailsBean baseBean, String result) {

            }
        });
    }
}
